package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.OnlinePickup;
import com.ruoyi.system.service.IOnlinePickupService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 在线提货Controller
 * 
 * @author ruoyi
 * @date 2024-02-20
 */
@RestController
@RequestMapping("/system/pickup")
public class OnlinePickupController extends BaseController
{
    @Autowired
    private IOnlinePickupService onlinePickupService;

    /**
     * 查询在线提货列表
     */
    @PreAuthorize("@ss.hasPermi('system:pickup:list')")
    @GetMapping("/list")
    public TableDataInfo list(OnlinePickup onlinePickup)
    {
        startPage();
        List<OnlinePickup> list = onlinePickupService.selectOnlinePickupList(onlinePickup);
        return getDataTable(list);
    }

    /**
     * 导出在线提货列表
     */
    @PreAuthorize("@ss.hasPermi('system:pickup:export')")
    @Log(title = "在线提货", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OnlinePickup onlinePickup)
    {
        List<OnlinePickup> list = onlinePickupService.selectOnlinePickupList(onlinePickup);
        ExcelUtil<OnlinePickup> util = new ExcelUtil<OnlinePickup>(OnlinePickup.class);
        util.exportExcel(response, list, "在线提货数据");
    }

    /**
     * 获取在线提货详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:pickup:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(onlinePickupService.selectOnlinePickupById(id));
    }

    /**
     * 新增在线提货
     */
    @PreAuthorize("@ss.hasPermi('system:pickup:add')")
    @Log(title = "在线提货", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OnlinePickup onlinePickup)
    {
        return onlinePickupService.insertOnlinePickup(onlinePickup);
    }

    /**
     * 修改在线提货
     */
    @PreAuthorize("@ss.hasPermi('system:pickup:edit')")
    @Log(title = "在线提货", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OnlinePickup onlinePickup)
    {
        return toAjax(onlinePickupService.updateOnlinePickup(onlinePickup));
    }

    /**
     * 删除在线提货
     */
    @PreAuthorize("@ss.hasPermi('system:pickup:remove')")
    @Log(title = "在线提货", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(onlinePickupService.deleteOnlinePickupByIds(ids));
    }
}
